export default {
  state: {
    chapterlist: []
  },
  getters: {

  },
  actions: {
    getChapter ({commit}, data) {
      fetch(`/xiaoliang/book-chapters/${data}`)
        .then(res => res.json())
        .then((data) => {
          console.log(data)
          commit('getChapterList', data.chapters)
        })
    }
  },
  mutations: {
    getChapterList (state, data) {
      state.chapterlist = data
      localStorage.setItem('chapters', JSON.stringify(state.chapterlist))
    }
  }
}
